<?php

namespace app\api\validate;

use think\Validate;

/**
 * 用户地址验证类
 * @package app\http\validates\user
 */
class AddressValidate extends Validate
{
    protected $regex = ['phone' => '/^1[3456789]\d{9}|([0-9]{3,4}-)?[0-9]{7,8}$/'];

    protected $rule = [
        'real_name' => 'require|max:25',
//        'gender' => 'require|in:1,2',
        'phone' => 'require|regex:phone',
//        'province' => 'require',
//        'city' => 'require',
//        'district' => 'require',
        'address' => 'require',
//        'detail' => 'require',
//        'longitude' => 'require',
//        'latitude' => 'require',
//        'tag' => 'require',
        'is_default' => 'require|in:1,0',
    ];

    protected $message = [
        'real_name.require' => '联系人必须填写',
        'real_name.max' => '联系人最多不能超过25个字符',
//        'gender.require' => '性别必须填写',
//        'gender.in' => '性别参数错误',
        'phone.require' => '手机号必须填写',
        'phone.regex' => '手机号格式错误',
//        'province.require' => '省必须填写',
//        'city.require' => '市名称必须填写',
//        'district.require' => '区/县名称必须填写',
        'address.require' => '详细地址必须填写',
//        'detail.require' => '门牌号必须填写',
//        'longitude.require' => '经度必须填写',
//        'latitude.require' => '纬度必须填写',
//        'tag.require' => '标签必须填写',
        'is_default.require' => '是否默认必须填写',
        'is_default.in' => '是否默认参数错误',
    ];
}